﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Temp.View
{
    class ComicStripDrawer
    {
        private Vector2 CONTINUEPOS = new Vector2(1200, 700);

        private ContentManager content;
        private Texture2D continueButton;
        private Rectangle continueRect;
        private AlexGame alexGame;
        private MouseState mouse, mousePast;
        private Rectangle mouseBox;

        public string comicStripLocation { get; set; }


        /// <summary>
        /// Constructor for the ComicStripDrawer
        /// </summary>
        /// <param name="content">ContentManager instance responsible for loading the images</param>
        /// <param name="alexGame">Passes the instance of AlexGame class</param>
        public ComicStripDrawer(ContentManager content, AlexGame alexGame)
        {
            this.content = content;
            this.alexGame = alexGame;

        }
        /// <summary>
        /// Loads the art assets to be used by ComicStripDrawer
        /// </summary>
        public void LoadContent()
        {
            continueButton = content.Load<Texture2D>("UI elements/continue");
            continueRect = new Rectangle((int)CONTINUEPOS.X, (int)CONTINUEPOS.Y, continueButton.Width, continueButton.Height);
            continueButton = content.Load<Texture2D>("UI elements/continue");
            comicStripLocation = "";
            mouseBox = new Rectangle(0, 0, 30, 30);
   
        }
        /// <summary>
        /// Checks whether the continue button has been pressed
        /// </summary>
        public void Update()
        {
            mouse = Mouse.GetState();
            mouseBox.X = mouse.X;
            mouseBox.Y = mouse.Y;

            if (mouse.LeftButton == ButtonState.Pressed && mouseBox.Intersects(continueRect) && mousePast.LeftButton == ButtonState.Released)
            {
                alexGame.drawAlexWorld = true;
                comicStripLocation = "";
                Mouse.SetPosition(0, 0);
            }

            mousePast = mouse;
        }
        /// <summary>
        /// Draws the comic strip and the continue button
        /// </summary>
        /// <param name="spriteBatch"></param>
        public void Draw(SpriteBatch spriteBatch)
        {

            if (comicStripLocation != "")
            {
                spriteBatch.Draw(content.Load<Texture2D>(comicStripLocation), new Vector2(0, 0), Color.White);
                spriteBatch.Draw(continueButton, CONTINUEPOS, Color.White);
            }
        }

    }
}
